<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

<rich:panel header="Agent Agreement Transfer" rendered="#{! agentAgreementTransferBean.search}">
	<h:panelGrid>
		<h:outputText value="#{errorBean.errorMessage}" styleClass="error"></h:outputText>
	</h:panelGrid>

	<t:panelGrid columns="2"
		columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80"
		width="100%">
		<h:outputText></h:outputText>
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputText value="#{messages['instruction']}"
				styleClass="standardText_Instruction" />
		</h:panelGroup>

		<h:outputText></h:outputText>
		<t:message for="prefix" styleClass="error"></t:message>

		<h:panelGroup>
			<h:outputLabel value="From Agent" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:outputLabel styleClass="standardText"
				value="#{agentAgreementTransferBean.agent.agentRegNo}"></t:outputLabel>
		</h:panelGroup>

		<h:outputText></h:outputText>
		<t:message for="size" styleClass="error"></t:message>

		<h:panelGroup>
			<h:outputLabel value="Terminated Date"
				styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:outputLabel styleClass="standardText"
				value="#{adminAgentRegApprBean.agent.createdDate}">
				<f:convertDateTime pattern="dd/MM/yyyy" timeZone="Asia/Kuala_Lumpur" />
			</t:outputLabel>
		</h:panelGroup>
		
		<h:outputText></h:outputText>
		<t:message for="toAgentId" styleClass="error"></t:message>
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="toAgentId" value="To Agent" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:inputText styleClass="standardText" readonly="true"
				value="#{agentAgreementTransferBean.toAgent.agentRegNo}"></t:inputText>
			<t:commandButton value="Search" styleClass="button" immediate="true" action="#{agentAgreementTransferBean.searchAction}"/>
			<t:inputHidden id="toAgentId" value="#{agentAgreementTransferBean.toAgent.agentId}" required="true"/>
		</h:panelGroup>
		<h:outputText></h:outputText>
	</t:panelGrid>
	<rich:spacer height="20" />

		<rich:dataTable id="data2" var="obj"  
			value="#{agentAgreementTransferBean.agreements}" rows="10" width="99%"
			rowKeyVar="rowNo">
			<rich:column style="text-align:center;width:5%;" >
				<f:facet name="header">
					<h:selectBooleanCheckbox id="chkAll" onclick="checkAll(this.form,this)" ></h:selectBooleanCheckbox>
				</f:facet>
				<h:selectBooleanCheckbox id="chk" value="#{obj.markAsAction}"></h:selectBooleanCheckbox>
			</rich:column>
			<rich:column style="text-align:center;width:20%;">
				<f:facet name="header">
					<h:outputText value="Agreement No."></h:outputText>
				</f:facet>
				<h:outputLabel value="#{obj.agreetmentNo}">
				</h:outputLabel>
			</rich:column>
			<rich:column style="text-align:center;width:20%;">
				<f:facet name="header">
					<h:outputText value="Member Name"></h:outputText>
				</f:facet>
				<t:outputText styleClass="standardText" value="#{obj.member.name}"></t:outputText>
			</rich:column>
			<rich:column style="text-align:center;width:20%;">
				<f:facet name="header">
					<h:outputText value="Agreement Date">
						<f:convertDateTime pattern="dd/MM/yyyy" timeZone="Asia/Kuala_Lumpur" />
					</h:outputText>
				</f:facet>
				<t:outputText styleClass="standardText" value="#{obj.agreetmentDate}"></t:outputText>
			</rich:column>
			<rich:column style="text-align:center;width:20%;">
				<f:facet name="header">
					<h:outputText value="Membership Category"></h:outputText>
				</f:facet>
				<t:outputText styleClass="standardText" value="#{obj.membership.membershipCategory.name}"></t:outputText>
			</rich:column>

		</rich:dataTable>

		<rich:spacer height="30" />

		<rich:datascroller align="left" for="data2" maxPages="20" />

		<h:panelGroup></h:panelGroup>
		<h:panelGroup></h:panelGroup>

		<h:panelGroup></h:panelGroup>

		<t:panelGroup>
			<t:panelGrid columns="2">
				<h:commandButton value="Transfer" styleClass="button"
					action="#{agentAgreementTransferBean.transferAction}"></h:commandButton>
				<h:commandButton value="#{messages['back']}" styleClass="button"
					action="#{adminAgentMgmtBean.navListAction}"
					immediate="true"></h:commandButton>
			</t:panelGrid>
		</t:panelGroup>


</rich:panel>




<rich:panel header="Search Agent List" rendered="#{agentAgreementTransferBean.search}">

		<t:panelGrid columns="2"
			columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80"
			width="100%">
			<h:outputLabel for="code"
				value="#{messages['agent.registration.no']}"
				styleClass="standardText_Label" />
			<t:inputText id="code" size="30" maxlength="50"
				styleClass="standardText"
				value="#{agentAgreementTransferBean.regno}"></t:inputText>

			<h:outputLabel for="cname" value="#{messages['company.name']}"
				styleClass="standardText_Label" />
			<t:inputText id="cname" size="30" maxlength="50"
				styleClass="standardText" value="#{agentAgreementTransferBean.name}"></t:inputText>

			<t:outputText></t:outputText>
			<h:commandButton value="#{messages['search']}" styleClass="button"
				action="#{agentAgreementTransferBean.searchAction}"></h:commandButton>
		</t:panelGrid>

		<rich:spacer height="20" />

		<rich:dataTable id="data" var="obj"
			value="#{agentAgreementTransferBean.agentList}" rows="10" width="99%"
			rowKeyVar="rowNo">

			<rich:column style="text-align:center;width:15%;">
				<f:facet name="header">
					<h:outputText value="#{messages['registration.no']}"></h:outputText>
				</f:facet>
				<h:commandLink rendered="#{obj.status=='agent.status.approved.agent'}"
					action="#{agentAgreementTransferBean.navAgreementTransfer}" immediate="true"
					actionListener="#{agentAgreementTransferBean.selectToAgent}"
					value="#{obj.agentRegNo}">
				</h:commandLink>
				<h:outputLabel rendered="#{!(obj.status=='agent.status.approved.agent')}" value="#{obj.agentRegNo}">
				</h:outputLabel>
				<f:param id="toAgentId" value="#{obj.agentId}" />
				<%--<t:outputText styleClass="standardText" value="#{obj.agentRegNo}"></t:outputText>--%>
			</rich:column>
			<rich:column style="text-align:center;width:15%;">
				<f:facet name="header">
					<h:outputText value="#{messages['contact.person']}"></h:outputText>
				</f:facet>
				<t:outputText styleClass="standardText" value="#{obj.contactPerson}"></t:outputText>
			</rich:column>
			<rich:column style="text-align:center;width:15%;">
				<f:facet name="header">
					<h:outputText value="#{messages['company.name']}"></h:outputText>
				</f:facet>
				<t:outputText styleClass="standardText" value="#{obj.compName}"></t:outputText>
			</rich:column>
			<rich:column style="text-align:center;width:13%;">
				<f:facet name="header">
					<h:outputText value="#{messages['status']}"></h:outputText>
				</f:facet>
				<t:outputText styleClass="standardText" value="#{obj.statusLabel}"></t:outputText>
			</rich:column>

		</rich:dataTable>

		<rich:spacer height="30" />

		<rich:datascroller align="left" for="data" maxPages="20" />

		<rich:spacer height="30" />

		<t:panelGrid columns="1" width="100%">
			<t:panelGroup>

				<h:commandButton value="#{messages['cancel']}" styleClass="button"
					immediate="true" action="#{agentAgreementTransferBean.navAgreementTransfer}"></h:commandButton>
			</t:panelGroup>
		</t:panelGrid>
	</rich:panel>